<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:75:"E:\phpstudy_pro\WWW\c\public/../application/after\view\after\recycling.html";i:1630665309;}*/ ?>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<table class="table">
    <tr>
        <td>
            <a href="/after/show/show">返回展示界面</a>
        </td>
        <td>
            <form action="http://www.admin.com/home/home/recycling" method="get">
                <input type="text" name="word">
                <input type="submit" value="搜索">
            </form>
        </td>
    </tr>

    <tr>
        <th>
            <a href="#" onclick="fu()">选定</a>
            <a href="#" class="delall" onclick="delall()">批量删除</a>
        </th>
        <th>ID</th>
        <th>订单编号</th>
        <th>下单日期</th>
        <th>收货人</th>
        <th>支付方式</th>
        <th>总金额</th>
        <th>订单状态</th>
        <th>操作</th>
    </tr>
    <?php foreach($data as $k=>$v): ?>
    <tr class="success">
        <td><input type="checkbox" value="<?php echo $v['id']; ?>" name="id"></td>
        <td><?php echo $v['id']; ?></td>
        <td><?php echo $v['o_order_id']; ?></td>
        <td><?php echo $v['o_order_time']; ?></td>
        <td><?php echo $v['o_consignee']; ?></td>
        <td><?php echo $v['o_mode']; ?></td>
        <td><?php echo $v['o_amount']; ?></td>
        <td>
            <?php if($v['o_state']==1): ?>
            <a href="#">
                未付款
            </a>
            <?php endif; if($v['o_state']==2): ?>
            <a href="#">
                已付款
            </a>
            <?php endif; if($v['o_state']==3): ?>
            <a class="state<?php echo $v['id']; ?>" href="#">
                未发货
            </a>
            <?php endif; if($v['o_state']==4): ?>
            <a state<?php echo $v['id']; ?> href="#">
                已发货
            </a>
            <?php endif; ?>
        </td>
        <td>
            <a href="/after/after/delete?id=<?php echo $v['id']; ?>">彻底删除</a>
            &emsp;
            <a href="/after/after/restore?id=<?php echo $v['id']; ?>">恢复</a>
        </td>
    </tr>
    <?php endforeach; ?>
</table>
<?php echo $data->render(); ?>

<script src="https://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js">
</script>
<script>
    function fu() {

        $(":checkbox").each(function (k, v) {
            v['checked'] = !v['checked']
        })
    }

    //批量删除
    function delall() {
        var token = localStorage.getItem('token');
        var arr = [];
        $(':checkbox:checked').each(function (i, v) {
            //向数组中添加元素
            arr.push($(v).val());
        })
        // 书写ajax
        $.ajax({
            'url': "http://www.admin.com/home/home/checkDel?id=" + arr + '&token=' + token,
            'type': 'GET',
            'dataType': 'JSON',
            success: function (e) {
                console.log(e)
                $(':checkbox :checked').each(function (k, v) {
                    $(v).parents('tr').remove()
                })
            }
        })
    }


</script>
